<!DOCTYPE html>
<html>
<head>
    <include file="Include:meta"/>
    <title>管理月报表-目的地运营集团数据管理平台</title>
    <include file="Include:style"/>
    <style>
        .background {
            background: #f5f5f5;
        }
    </style>
</head>
<body>
<include file="Include:header"/>
<include file="Include:left"/>
<div id="main">
    <div class="crumbs">
        <div class="crumbs-text">管理月报表</div>
        <div class="right">
            <a href="__APP__/Report/excel/cdepcode/{$cdepcode}/iyear/{$iyear}" class="btn left mr5">导出Excel</a>
        </div>
    </div>
    <div id="content">
        <div class="filter">
            <form name="__APP__/Report/index" method="post">
                <div class="filter-item">
                    <div class="filter-title">
                    <span>部门名称：
                    <select class="form-control" name="cdepcode" autocomplete="off">
                        <option value="">请选择部门</option>
                        <foreach name="res_department_mapping" item="vo">
                            <option <if condition="$cdepcode eq $vo['id']">selected</if> value="{$vo['id']}">
                            <if condition="$vo['level'] eq 3">&nbsp;&nbsp;└<elseif condition="$vo['level'] eq 4"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;└
                            </if>{$vo['ehr_deptname']}
                            </option>
                        </foreach>
                    </select>
                    </span>
                        <span>年份：
                    <select class="form-control" name="iyear" autocomplete="off">
                        <for start="2018" end="2021">
                        <option <if condition="$iyear eq $i">selected</if> value="{$i}">{$i}</option>
                        </for>
                    </select>
                    </span>
                        <span><button class="btn found_btn" type="submit">搜索</button></span>
                    </div>
                </div>
            </form>
        </div>
        <div class="table-scrollx">
            <table class="table table-bordered">
                <tr class="table-header fixed-table-header">
                    <td>科目</td>
                    <for start="1" end="13">
                        <td class="w100">{$i}月</td>
                    </for>
                    <td>合计</td>
                </tr>
                <if condition="$result eq NULL">
                    <tr>
                        <td class="text-center" colspan="14">暂无相关内容</td>
                    </tr>
                </if>
                <foreach name="result" item="vo" key="key">
                    <tr style="background-color:green">
                        <td class="w300"><a style="color: white;font-weight:bold" class="xm_btn"
                                            href="__APP__/Report/detail/subject/{$vo['subject_codes']}/ehr_department_id/{$cdepcode}/year/{$iyear}">{$vo['report_subject_name']}</a>
                        </td>
                        <for start="1" end="12" comparison="elt">
                            <td><a style="color: white;"
                                   href="__APP__/Report/detail/subject/{$vo['subject_codes']}/ehr_department_id/{$cdepcode}/iperiod/{$iyear}-{$i}">{:float_money($vo[$i])}</a>
                            </td>
                        </for>
                        <td style="color: white;">{:float_money($vo['sum'])}</td>
                    </tr>
                    <foreach name="vo['level2']" item="v" key="k">
                        <tr>
                            <td class="w300"><a style="color:black;font-weight:bold;" class="xm_btn"
                                                href="__APP__/Report/detail/subject/{$v['subject_codes']}/ehr_department_id/{$cdepcode}/year/{$iyear}">&nbsp;&nbsp;└{$v['report_subject_name']}</a>
                            </td>
                            <for start="1" end="12" comparison="elt">
                                <td><a style="color:black;"
                                       href="__APP__/Report/detail/subject/{$v['subject_codes']}/ehr_department_id/{$cdepcode}/iperiod/{$iyear}-{$i}">{:float_money($v[$i])}</a>
                                </td>
                            </for>
                            <td style="color: red;">{:float_money($v['sum'])}</td>
                        </tr>
                    </foreach>

                </foreach>
                <tr style="background-color:green">
                    <td style="color: white;font-weight:bold" colspan="14">汇总计算</td>


                </tr>
                <tr style="color: red">
                    <td>毛利</td>
                    <for start="1" end="12" comparison="elt">
                        <td>{:calculateGross($result[0][$i],$result[8][$i])}</td>
                    </for>
                    <td>{:calculateGross($result[0]['sum'],$result[8]['sum'])}</td>
                </tr>
                <tr style="color: red">
                    <td>毛利率</td>
                    <for start="1" end="12" comparison="elt">
                        <td>{:calculateGrossRate($result[0][$i],$result[8][$i])}</td>
                    </for>
                    <td>{:calculateGrossRate($result[0]['sum'],$result[8]['sum'])}</td>
                </tr>
                <tr style="color: red">
                    <td>税前利润</td>
                    <for start="1" end="12" comparison="elt">
                        <td>
                            {:calculateProfitTax($result[0][$i],$result[8][$i],$result[1][$i],$result[2][$i],$result[3][$i],$result[4][$i],$result[5][$i],$result[6][$i])}
                        </td>
                    </for>
                    <td>
                        {:calculateProfitTax($result[0]['sum'],$result[8]['sum'],$result[1]['sum'],$result[2]['sum'],$result[3]['sum'],$result[4]['sum'],$result[5]['sum'],$result[6]['sum'])}
                    </td>
                </tr>
                <tr style="color: red">
                    <td>净利润</td>
                    <for start="1" end="12" comparison="elt">
                        <td>
                            {:calculateRetainedProfit($result[0][$i],$result[8][$i],$result[1][$i],$result[2][$i],$result[3][$i],$result[4][$i],$result[5][$i],$result[6][$i],$result[7][$i])}
                        </td>
                    </for>
                    <td>
                        {:calculateRetainedProfit($result[0]['sum'],$result[8]['sum'],$result[1]['sum'],$result[2]['sum'],$result[3]['sum'],$result[4]['sum'],$result[5]['sum'],$result[6]['sum'],$result[7]['sum'])}
                    </td>
                </tr>
            </table>
        </div>
    </div>
</div>
<include file="Include:javascript"/>

</body>
</html>